<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta HTTP-EQUIV="pragma" CONTENT="no-cache">
    <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
    <meta HTTP-EQUIV="expires" CONTENT="0">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>项目管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/font-awesome.css" rel="stylesheet">
    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">
    <link href="css/ui.css" rel="stylesheet">
    <link rel="stylesheet" href="css/control.css">
    <style>
        #body {
            width: 100%;
            max-height: 100%;
            overflow-y: scroll;
            overflow-x: hidden;
        }

        .articleImg {
            /* width: 100%; */
            /* height: auto !important; */
            max-width: 100px;
        }

        th,
        td {
            text-align: center;
        }
        .form-group-self {
            margin-top: 15px;
            margin-bottom: 20px;
        }
    </style>
</head>

<body class="gray-bg animated fadeInRight">
<div id="body">
    <div class="wrapper wrapper-content">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">

                    <div class="form-group-self">
                        <div class="col-sm-2">
                            <div class="form-group">
                                <input type="text" class="form-control" id="projectName" placeholder="项目名称">
                            </div>
                        </div>
                        <div class="col-sm-1">
                            <button class="btn btn-success btn-sm" title="搜索" id="search">搜索</button>
                        </div>
                        <div class="fr" style="">
                            <a href="projectAdd.html" class="btn btn-info btn-sm" title="项目创建">项目创建</a>
                        </div>
                    </div>

                    <div class="ibox-content">
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th width="30%">项目名称</th>
                                <th width="18%">操作人</th>
                                <th width="30%">创建时间</th>
                                <th width="12%">操作</th>
                            </tr>
                            </thead>
                            <tbody id="list">
                            </tbody>
                        </table>
                    </div>
                    <!--<div id="pageRow" class="fixBottom">
                        <div class="fr" id="page">
                            <ul class="pagination" style="margin:0;float:right;">
                                <li class="paginate_button" id="firstPage">
                                    <a href="javascript:">
                                        <<</a>
                                </li>
                                <li class="paginate_button" id="previousPage">
                                    <a href="javascript:">
                                        <</a>
                                </li>
                                <li class="paginate_button">
                                    <a href="javascript:" style="padding:0">
                                        <select class="" name="" style="padding:4px 10px" id="pageInfo">
                                        </select>
                                    </a>
                                </li>
                                <li class="paginate_button" id="nextPage">
                                    <a href="javascript:">></a>
                                </li>
                                <li class="paginate_button" id="lastPage">
                                    <a href="javascript:">>></a>
                                </li>
                            </ul>
                        </div>
                        <div class="fr" style="margin-right:20px;">
                            <div class="dataTables_info" style="line-height:28px;">当前显示第
                                <span id="startRow"></span> 到
                                <span id="endRow"></span> 项，共
                                <span id="totalPage"></span> 项 ,每页显示
                                <select class="" name="" id="pageSizeInfo" style="margin:0 10px;">
                                    <option value="10">10</option>
                                    <option value="20">20</option>
                                    <option value="30">30</option>
                                    <option value="50">50</option>
                                </select>项</div>
                        </div>
                    </div>-->
                </div>
            </div>
        </div>
    </div>
</div>

<!-- 全局js -->
<script src="js/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/work/common.js"></script>
<script src="js/plugins/layer/layer.js"></script>
<!-- 自定义js -->
<script src="js/content.js"></script>
<script src="js/pileCommon.js"></script>
<script>
    var pageNum = getStorage("pageNum") || 1;
    var pageSize = getStorage("pageSize") || 20;
    var flag = 0;
    $(document).ready(function () {
        $("#pageSizeInfo").val(pageSize)
        var today = Date.parse(new Date())


        requestGetPileList();

        // 搜索
        $("#search").on("click", function () {
            requestGetPileList();
        });


    });

    function requestGetPileList() {
        var projectName=$('#projectName').val()==""?null:$('#projectName').val();
        var dataJson = {projectName:$('#projectName').val()};
        ajax({
            url: "pile/showPileProject",
            type: "GET",
            dataType: 'jsonp',
            jsonp: "callback",
            async: false,
           /* xhrFields: {
                withCredentials: true
            },
            crossDomain: true,*/
            data: {projectName:projectName},
            timeout: 10000,
            contentType: "application/json;charset=utf-8",
            error: function (xhr, type) {

            },
            successx: function (data) {
                if (data.success == true) {
                    creatList(data.data);
                    //createPageInfo(data.data);
                } else {
                    layer.msg(data.message, {time: 1000})
                }
            },
        });


    }

    function creatList(data) {
        var tpl = '';
        for (var i = 0; i < data.length; i++) {
            tpl += '<tr class="viewDb" data-val="' + data[i].id + '">' +
                '<td>' + data[i].name + '</td>' +
                '<td>' + setNull(data[i].operator) + '</td>' +
                /* '<td>' + data[i].concreteStrength + '</td>' +
                 '<td>' + determineName(data[i].status) + '</td>' +
                 '<td>' + concreteDesignGradeName(data[i].concreteDesignGrade) + '</td>' +
                 '<td>' + data[i].cPileLength + '</td>' +
                 '<td>' + integrityName(data[i].dPileIntegrity) + '</td>' +
                 '<td>' + sedimentName(data[i].sedimentThicknessStatus) + '</td>' +*/
                '<td>' + timeStamp2String(data[i].createTime, "ymdhms") + '</td>' +
                '<td>'
                + '<a class="update btn btn-xs btn-warning" pname="' + data[i].name + '">修改</a>&nbsp;&nbsp;&nbsp;'
            /*+ '<a class="delete btn btn-xs btn-danger">删除</a>&nbsp;&nbsp;&nbsp;'*/
            '</td>' +
            '</tr>'
        }
        $("#list").empty().append(tpl);

        // 添加项目
        $('.create').click(function () {
            /*var id = $(this).parent().parent().attr("data-val");
            setStorage("pileId", id);*/
            window.location.href = "projectAdd.html";
        });

        // 修改项目
        $('.update').click(function () {
            var pname = $(this).attr("pname");
            setStorage("pname", pname);
            var id = $(this).parent().parent().attr("data-val");
            setStorage("pid", id);
            window.location.href = "projectEdit.html";
        });


        // 删除
        $('.delete').click(function () {
            var id = $(this).parent().parent().attr("data-val");
            layer.confirm('确定要删除吗？', {btn: ['删除', '不删除'], title: '提示', icon: 3}, function (index) {
                // 删除请求
                requestDeletePile(id)
                layer.close(index);
            }, function (index) {
                layer.close(index);
            });
        });
    }



    //创建页码信息
    function createPageInfo(data) {
        $("#startRow").text(data.startRow)
        $("#endRow").text(data.endRow)
        $("#totalPage").text(data.total)
        var temp = '';
        for (var i = 1; i < data.pages + 1; i++) {
            temp += '<option value="' + i + '">' + i + '</option>'
        }
        $("#pageInfo").html(temp);
        $("#pageInfo").val(data.pageNum);
        $("#pageInfo").change(function () {
            $("#pageInfor").blur();
            if (flag == 1) {
                return
            };
            flag = 1
            pageNum = this.options[this.options.selectedIndex].value
            setStorage("pageNum", pageNum)
            getData()
        });
        $("#firstPage").click(function () {
            if (pageNum != 1) {
                if (flag == 1) {
                    return
                };
                flag = 1
                pageNum = 1
                setStorage("pageNum", pageNum)
                getData()
            }
        });
        $("#lastPage").click(function () {
            if (pageNum < data.pages) {
                if (flag == 1) {
                    return
                };
                flag = 1
                pageNum = data.pages
                setStorage("pageNum", pageNum)
                getData()
            }
        });
        $("#nextPage").click(function () {
            if (pageNum < data.pages) {
                if (flag == 1) {
                    return
                };
                flag = 1
                pageNum++
                setStorage("pageNum", pageNum)
                getData()
            }
        });
        $("#previousPage").click(function () {
            if (pageNum > 1) {
                if (flag == 1) {
                    return
                };
                flag = 1
                pageNum--
                setStorage("pageNum", pageNum)
                getData()
            }
        })
    }
</script>
</body>

</html>